<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="com.model.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" rev="stylesheet" href="../css/style.css" type="text/css" media="all" />
<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>
<script>
function save(){
	if(document.form.lpn.value == null || document.form.lpn.value == ""){
		alert("车牌必须填写");
		document.form.lpn.focus();
		return;
	}
	else if(document.form.model.value == null || document.form.model.value == ""){
		alert("车辆型号必须填写");
		document.form.model.focus();
		return;
	}
	else if(document.form.carry.value == null || document.form.carry.value == ""){
		alert("可载人数必须填写");
		document.form.carry.focus();
		return;
	}
	else if(confirm("确认保存？")){
		document.form.submit();			
	}
}
</script>
</head>

<body class="ContentBody">
<%
	request.setCharacterEncoding("UTF-8");
	response.setCharacterEncoding("UTF-8");

	Connection con = DataBase.getConnection();

	//TODO: rewrite the sql clause
	PreparedStatement pstmtInfo = con.prepareStatement("SELECT * FROM car where lpn=?");
	String lpn = URLDecoder.decode(request.getParameter("lpn"), "UTF-8");
	pstmtInfo.setString(1, lpn);
  	ResultSet rsInfo = pstmtInfo.executeQuery();
  	if( !rsInfo.next() )
  	{%>
	无效车牌号！请勿做非法输入！
	<%}
  	else{%>

<form action="CarDeal?flag=edit" method="post" name="form">
<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
      <th class="tablestyle_title" >车辆修改页面</th>
  </tr>
  <tr>
    <td class="CPanel">
		
		<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
		<tr><td align="left">
		<input type="button" name="Submit" value="保存" class="button" onclick="save();"/>　
			
			<input type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/>
		</td></tr>
		<tr>
			<td width="100%">
				<fieldset style="height:100%;">
				<legend>车辆信息</legend>
					  <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
					  <tr>
					    <td nowrap="nowrap" align="right" width="15%">车牌号:</td>
					    <td width="35%"><input name='lpn' type="text" class="text" style="width:154px" value="<%=rsInfo.getString("lpn") %>" />
				        </td>

					    <td nowrap="nowrap" align="right" width="18%">车辆型号:</td>
					    <td width="35%"><input name='model' type="text" class="text" style="width:154px" value="<%=rsInfo.getString("model") %>" />
				        </td>
					    </tr>
					    
						<tr>
					    <td nowrap="nowrap" align="right" width="15%">可载人数:</td>
					    <td width="35%"><input name='carry' type="text" class="text" style="width:154px" value="<%=rsInfo.getString("carry") %>" />	
                        </td>
				         <td nowrap="nowrap" align="right" width="18%">所属车队:</td>
					    <td width="35%">
					    	<select name='team' type="text" class="text" style="width:154px" value="" >
					    	<%=rsInfo.getBoolean("team")?"<option>外车</option>":"<option>本校</option>" %>
					    	<%=rsInfo.getBoolean("team")?"<option>本校</option>":"<option>外车</option>" %>
					    	</select>	
                        </td>
                        </tr>
					  </table>
			  <br />
				</fieldset>			</td>
		</tr>
		</table>
	 </td>
  </tr>
		<tr>
			<td colspan="2" align="center" height="50px">
			<input type="button" name="Submit" value="保存" class="button" onclick="save()"/>　
			
			<input type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/></td>
		</tr>
		</table>
</div>
</form>
<%}
	rsInfo.close();
	con.close();
%>
</body>
</html>
